﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using Sinacor.OMM.HealthMonitor.Collector;
using Sinacor.OMM.HFTMessageManager.ProcessLogic;

namespace Sinacor.OMM.HFTMessageManager
{
    partial class HFTMessageManagerService : ServiceBase
    {
        Sinacor.OMM.HFTMessageManager.ProcessLogic.STMMessageFlow STMMessageFlow = null;
        HealthMonitorCollector _healthMonitor;

        public HFTMessageManagerService()
        {
            InitializeComponent();
            this.ServiceName = "BM&FBOVESPA HFT Message Manager Service";
        }

        protected override void OnStart(string[] args)
        {
            //while (!System.Diagnostics.Debugger.IsAttached)
            //    System.Threading.Thread.Sleep(1000);

            STMMessageFlow = new STMMessageFlow();
            Thread thrMain = new Thread(new ThreadStart(STMMessageFlow.Start));
            thrMain.Start();

            _healthMonitor = HealthMonitorCollector.GetInstance();
        }

        protected override void OnStop()
        {
            _healthMonitor.Dispose();
            STMMessageFlow.Dispose();
        }
    }
}
